<?php
class Model_Catalog extends Zend_Db_Table_Abstract {
	protected $DataAp;
	public function __construct() {
		$this->DataAp = Zend_Registry::get ( "db" );
	}	
	public function getItems($sort, $order, $offset, $rows) {
		$result = array();
        $query = $this->DataAp->query ( "SELECT COUNT(*) AS Total FROM  user  where id !=1 " );
        $row = $query->fetchAll ();            
		$query = $this->DataAp->query ( "SELECT id, name,luong,ngaynghi,trocap,ghichu,luongngay,tamung, (luong - tamung - (ngaynghi*luongngay) + trocap ) as thuclinh 
		FROM user where id !=1 ORDER BY $sort $order LIMIT $offset, $rows "  );
		$result ["total"] = $row [0] ['Total'];
		$result ["rows"] = $query->fetchAll ();
		return $result;
	}
	public function getItemsds($sort, $order, $offset, $rows) {
		$result = array();
        $query = $this->DataAp->query ( "SELECT COUNT(*) AS Total FROM  user  where id !=1 " );
        $row = $query->fetchAll ();            
		$query = $this->DataAp->query ( "SELECT id,nameuser,created, name,luong,ngaynghi,trocap,ghichu,luongngay,tamung, (luong - tamung - (ngaynghi*luongngay) + trocap ) as thuclinhs  
		FROM bangluong ORDER BY $sort $order LIMIT $offset, $rows "  );
		$result ["total"] = $row [0] ['Total'];
		$result ["rows"] = $query->fetchAll ();
		return $result;
	}
	
	public function thanhtoans($id, $data) {
		$Id = $this->DataAp->update ( 'user', $data, 'id = ' . $id );
		return $Id;
	}
	public function update($id, $data) {
		$Id = $this->DataAp->update ( 'user', $data, 'id = ' . $id );
		return $Id;
	}
	public function updateds($id, $data) {
		$Id = $this->DataAp->update ( 'bangluong', $data, 'id = ' . $id );
		return $Id;
	}
	public function del($id) {
		$Id = $this->DataAp->delete ( 'bangluong', 'id = ' . $id );
		return $Id;
	}
	public function addObj($data) {
		$Id = $this->DataAp->insert ( 'bangluong', $data );
		return $Id;
	} 
	public function getFetObjByMaphieunhapExcel($mapn) {
		$query = $this->DataAp->query (  "SELECT  * FROM user WHERE id = $mapn " );
		return $query->fetchAll ();
	}
	public function getFetObjByMaphieunhapsExcel() {
		$query = $this->DataAp->query (  "SELECT  * FROM user " );
		return $query->fetchAll ();
	}
}
?>
   
   

